home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 June: Reference Library / Dev.CD Jun 96 RL / Dev.CD Jun 96 RL.toast / What's New? / Development Kits / Apple Game Sprockets DR1 / Examples / NetSprocketTest / NSTestApp.h < prev   
Encoding:
C/C++ Source or Header  |  1996-04-24  |  2.2 KB  |  90 lines  |  [TEXT/MPS ]

  1.  
  2. #pragma once
  3.  
  4. #include <LApplication.h>
  5.  
  6. #include "NetSprocket.h"
  7. #include <LArray.h>
  8. #include <LComparator.h>
  9. #include <LWindow.h>
  10.  
  11. typedef struct TKeyState
  12. {
  13.     TNetMessageHeader    h;
  14.     UInt32                keyMap[4];
  15.     UInt32                pulseBit;
  16. } TKeyState;
  17.  
  18. UInt32 gPulseBit;
  19.  
  20. typedef struct PlayerListItem
  21. {
  22.     TPlayerID    player;
  23.     LWindow        *window;
  24. } PlayerListItem;
  25.  
  26. class CPlayerListComparator : LComparator
  27. {
  28. public:
  29.     CPlayerListComparator() {}
  30.     ~CPlayerListComparator() {}
  31.     virtual Int32        Compare(
  32.                                 const void*            inItemOne,
  33.                                 const void*         inItemTwo,
  34.                                 Uint32                inSizeOne,
  35.                                 Uint32                inSizeTwo) const;
  36.                                 
  37.     virtual Boolean        IsEqualTo(
  38.                                 const void*            inItemOne,
  39.                                 const void*         inItemTwo,
  40.                                 Uint32                inSizeOne,
  41.                                 Uint32                inSizeTwo) const;
  42.     virtual    Int32        CompareToKey(
  43.                                 const void*            inItem,
  44.                                 Uint32                inSize,
  45.                                 const void*            inKey) const;
  46.                                 
  47.     virtual    Boolean        IsEqualToKey(
  48.                                 const void*            inItem,
  49.                                 Uint32                inSize,
  50.                                 const void*            inKey) const;
  51.  
  52.  
  53. };
  54.  
  55.  
  56. class    PPTestApp : public LApplication {
  57. public:
  58.                         PPTestApp();        // constructor registers all PPobs
  59.     virtual             ~PPTestApp();        // stub destructor
  60.     
  61.         // this overriding function performs application functions
  62.         
  63.     virtual void        ProcessNextEvent(void);
  64.     virtual Boolean        ObeyCommand(CommandT inCommand, void* ioParam);    
  65.     
  66.         // this overriding function returns the status of menu items
  67.         
  68.     virtual void        FindCommandStatus(CommandT inCommand,
  69.                             Boolean &outEnabled, Boolean &outUsesMark,
  70.                             Char16 &outMark, Str255 outName);
  71. protected:
  72.  
  73.     virtual void        StartUp();        // overriding startup functions
  74.             void        HandleGameEvent(TNetMessageHeader *inEvent);
  75.             void        HandlePlayerJoined(TPlayerJoinedMessage *inEvent);
  76.             void        HandlePlayerLeft(TPlayerLeftMessage *inEvent);
  77.             void        HandleGameStart(TNetMessageHeader *inEvent);
  78.             void        HandleGamePause(TNetMessageHeader *inEvent);
  79.             void        HandleGameEnd(TNetMessageHeader *inEvent);
  80.             void        HandleKeyboardState(TKeyState *inEvent);
  81.             
  82.     TNetGameObject        theGame;
  83.     Boolean                bAdvertising;
  84.     Boolean                bHost;
  85.     Boolean                bRunning;
  86.     UInt32                 mPlayerCount;
  87.     TPlayerID            mPlayerID;
  88.     LArray                *mPlayerList;            
  89.     
  90. };